import plotly
plotly.offline.init_notebook_mode()
import numpy as np
import pandas as pd
# from google.colab import files
# uploaded = files.upload()
# from google.colab import files
# uploaded = files.upload()
df1=pd.read_csv("data\country_vaccinations.csv")
df2=pd.read_csv("data\country_vaccinations_by_manufacturer.csv")
df1.head()
| country | iso_code | date | total_vaccinations | people_vaccinated | people_fully_vaccinated | daily_vaccinations_raw | daily_vaccinations | total_vaccinations_per_hundred | people_vaccinated_per_hundred | people_fully_vaccinated_per_hundred | daily_vaccinations_per_million | vaccines | source_name | source_website | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | Afghanistan | AFG | 2021-02-22 | 0.0 | 0.0 | NaN | NaN | NaN | 0.0 | 0.0 | NaN | NaN | Johnson&Johnson, Oxford/AstraZeneca, Pfizer/Bi... | World Health Organization | https://covid19.who.int/ |
| 1 | Afghanistan | AFG | 2021-02-23 | NaN | NaN | NaN | NaN | 1367.0 | NaN | NaN | NaN | 34.0 | Johnson&Johnson, Oxford/AstraZeneca, Pfizer/Bi... | World Health Organization | https://covid19.who.int/ |
| 2 | Afghanistan | AFG | 2021-02-24 | NaN | NaN | NaN | NaN | 1367.0 | NaN | NaN | NaN | 34.0 | Johnson&Johnson, Oxford/AstraZeneca, Pfizer/Bi... | World Health Organization | https://covid19.who.int/ |
| 3 | Afghanistan | AFG | 2021-02-25 | NaN | NaN | NaN | NaN | 1367.0 | NaN | NaN | NaN | 34.0 | Johnson&Johnson, Oxford/AstraZeneca, Pfizer/Bi... | World Health Organization | https://covid19.who.int/ |
| 4 | Afghanistan | AFG | 2021-02-26 | NaN | NaN | NaN | NaN | 1367.0 | NaN | NaN | NaN | 34.0 | Johnson&Johnson, Oxford/AstraZeneca, Pfizer/Bi... | World Health Organization | https://covid19.who.int/ |
df2.head()
| location | date | vaccine | total_vaccinations | |
|---|---|---|---|---|
| 0 | Argentina | 2020-12-29 | Moderna | 2 |
| 1 | Argentina | 2020-12-29 | Oxford/AstraZeneca | 3 |
| 2 | Argentina | 2020-12-29 | Sinopharm/Beijing | 1 |
| 3 | Argentina | 2020-12-29 | Sputnik V | 20481 |
| 4 | Argentina | 2020-12-30 | Moderna | 2 |
df1.describe()
| total_vaccinations | people_vaccinated | people_fully_vaccinated | daily_vaccinations_raw | daily_vaccinations | total_vaccinations_per_hundred | people_vaccinated_per_hundred | people_fully_vaccinated_per_hundred | daily_vaccinations_per_million | |
|---|---|---|---|---|---|---|---|---|---|
| count | 4.360700e+04 | 4.129400e+04 | 3.880200e+04 | 3.536200e+04 | 8.621300e+04 | 43607.000000 | 41294.000000 | 38802.000000 | 86213.000000 |
| mean | 4.592964e+07 | 1.770508e+07 | 1.413830e+07 | 2.705996e+05 | 1.313055e+05 | 80.188543 | 40.927317 | 35.523243 | 3257.049157 |
| std | 2.246004e+08 | 7.078731e+07 | 5.713920e+07 | 1.212427e+06 | 7.682388e+05 | 67.913577 | 29.290759 | 28.376252 | 3934.312440 |
| min | 0.000000e+00 | 0.000000e+00 | 1.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000 | 0.000000 | 0.000000 | 0.000000 |
| 25% | 5.264100e+05 | 3.494642e+05 | 2.439622e+05 | 4.668000e+03 | 9.000000e+02 | 16.050000 | 11.370000 | 7.020000 | 636.000000 |
| 50% | 3.590096e+06 | 2.187310e+06 | 1.722140e+06 | 2.530900e+04 | 7.343000e+03 | 67.520000 | 41.435000 | 31.750000 | 2050.000000 |
| 75% | 1.701230e+07 | 9.152520e+06 | 7.559870e+06 | 1.234925e+05 | 4.409800e+04 | 132.735000 | 67.910000 | 62.080000 | 4682.000000 |
| max | 3.263129e+09 | 1.275541e+09 | 1.240777e+09 | 2.474100e+07 | 2.242429e+07 | 345.370000 | 124.760000 | 122.370000 | 117497.000000 |
df2.describe()
| total_vaccinations | |
|---|---|
| count | 3.562300e+04 |
| mean | 1.508357e+07 |
| std | 5.181768e+07 |
| min | 0.000000e+00 |
| 25% | 9.777600e+04 |
| 50% | 1.305506e+06 |
| 75% | 7.932423e+06 |
| max | 6.005200e+08 |
import matplotlib.pyplot as plt
import seaborn as sns
import matplotlib
%matplotlib inline
import plotly.express as px
sns.set_style('darkgrid')
matplotlib.rcParams['font.size'] = 12
matplotlib.rcParams['figure.facecolor'] = '#00000000'
matplotlib.rcParams['figure.figsize'] = (10, 6)
plt.rc('font', size=11)
India_data=df1[df1["iso_code"]=="IND"]
India_data.head()
| country | iso_code | date | total_vaccinations | people_vaccinated | people_fully_vaccinated | daily_vaccinations_raw | daily_vaccinations | total_vaccinations_per_hundred | people_vaccinated_per_hundred | people_fully_vaccinated_per_hundred | daily_vaccinations_per_million | vaccines | source_name | source_website | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 35372 | India | IND | 2021-01-15 | 0.0 | 0.0 | NaN | NaN | NaN | 0.00 | 0.00 | NaN | NaN | Covaxin, Oxford/AstraZeneca, Sputnik V | Government of India | https://dashboard.cowin.gov.in/ |
| 35373 | India | IND | 2021-01-16 | 191181.0 | 191181.0 | NaN | 191181.0 | 191181.0 | 0.01 | 0.01 | NaN | 137.0 | Covaxin, Oxford/AstraZeneca, Sputnik V | Government of India | https://dashboard.cowin.gov.in/ |
| 35374 | India | IND | 2021-01-17 | 224301.0 | 224301.0 | NaN | 33120.0 | 112150.0 | 0.02 | 0.02 | NaN | 80.0 | Covaxin, Oxford/AstraZeneca, Sputnik V | Government of India | https://dashboard.cowin.gov.in/ |
| 35375 | India | IND | 2021-01-18 | 454049.0 | 454049.0 | NaN | 229748.0 | 151350.0 | 0.03 | 0.03 | NaN | 109.0 | Covaxin, Oxford/AstraZeneca, Sputnik V | Government of India | https://dashboard.cowin.gov.in/ |
| 35376 | India | IND | 2021-01-19 | 674835.0 | 674835.0 | NaN | 220786.0 | 168709.0 | 0.05 | 0.05 | NaN | 121.0 | Covaxin, Oxford/AstraZeneca, Sputnik V | Government of India | https://dashboard.cowin.gov.in/ |
India_data.fillna(0) #Replacing NaN values with 0
| country | iso_code | date | total_vaccinations | people_vaccinated | people_fully_vaccinated | daily_vaccinations_raw | daily_vaccinations | total_vaccinations_per_hundred | people_vaccinated_per_hundred | people_fully_vaccinated_per_hundred | daily_vaccinations_per_million | vaccines | source_name | source_website | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 35372 | India | IND | 2021-01-15 | 0.000000e+00 | 0.0 | 0.0 | 0.0 | 0.0 | 0.00 | 0.00 | 0.00 | 0.0 | Covaxin, Oxford/AstraZeneca, Sputnik V | Government of India | https://dashboard.cowin.gov.in/ |
| 35373 | India | IND | 2021-01-16 | 1.911810e+05 | 191181.0 | 0.0 | 191181.0 | 191181.0 | 0.01 | 0.01 | 0.00 | 137.0 | Covaxin, Oxford/AstraZeneca, Sputnik V | Government of India | https://dashboard.cowin.gov.in/ |
| 35374 | India | IND | 2021-01-17 | 2.243010e+05 | 224301.0 | 0.0 | 33120.0 | 112150.0 | 0.02 | 0.02 | 0.00 | 80.0 | Covaxin, Oxford/AstraZeneca, Sputnik V | Government of India | https://dashboard.cowin.gov.in/ |
| 35375 | India | IND | 2021-01-18 | 4.540490e+05 | 454049.0 | 0.0 | 229748.0 | 151350.0 | 0.03 | 0.03 | 0.00 | 109.0 | Covaxin, Oxford/AstraZeneca, Sputnik V | Government of India | https://dashboard.cowin.gov.in/ |
| 35376 | India | IND | 2021-01-19 | 6.748350e+05 | 674835.0 | 0.0 | 220786.0 | 168709.0 | 0.05 | 0.05 | 0.00 | 121.0 | Covaxin, Oxford/AstraZeneca, Sputnik V | Government of India | https://dashboard.cowin.gov.in/ |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 35806 | India | IND | 2022-03-25 | 1.826266e+09 | 980435665.0 | 824764568.0 | 1997100.0 | 2433734.0 | 131.06 | 70.36 | 59.19 | 1747.0 | Covaxin, Oxford/AstraZeneca, Sputnik V | Government of India | https://dashboard.cowin.gov.in/ |
| 35807 | India | IND | 2022-03-26 | 1.830285e+09 | 982687842.0 | 826360688.0 | 4019460.0 | 2830351.0 | 131.35 | 70.52 | 59.30 | 2031.0 | Covaxin, Oxford/AstraZeneca, Sputnik V | Government of India | https://dashboard.cowin.gov.in/ |
| 35808 | India | IND | 2022-03-27 | 1.831348e+09 | 983190780.0 | 826884564.0 | 1062451.0 | 2851859.0 | 131.43 | 70.56 | 59.34 | 2047.0 | Covaxin, Oxford/AstraZeneca, Sputnik V | Government of India | https://dashboard.cowin.gov.in/ |
| 35809 | India | IND | 2022-03-28 | 1.833040e+09 | 984051283.0 | 827610878.0 | 1692273.0 | 2736644.0 | 131.55 | 70.62 | 59.39 | 1964.0 | Covaxin, Oxford/AstraZeneca, Sputnik V | Government of India | https://dashboard.cowin.gov.in/ |
| 35810 | India | IND | 2022-03-29 | 1.834501e+09 | 984838143.0 | 828229455.0 | 1460643.0 | 2580123.0 | 131.66 | 70.68 | 59.44 | 1852.0 | Covaxin, Oxford/AstraZeneca, Sputnik V | Government of India | https://dashboard.cowin.gov.in/ |
439 rows × 15 columns
plt.figure(figsize=(20,5))
sns.lineplot(data=India_data,x="date",y="daily_vaccinations",marker='*',markersize= 8)
plt.title("Per day vaccinations population trend in India")
plt.tight_layout()
plt.show();
df4=India_data.iloc[::25][:]
df4=df4[1:][:]
df4.head()
# India_data_copy=df4[df4["iso_code"]=="IND"]
plt.figure(figsize=(25,9))
sns.lineplot(data=df4,x="date",y="daily_vaccinations",marker='*',markersize= 15)
plt.title("Per day vaccinations population trend in INDIA")
plt.tight_layout()
RUS_data=df1[df1["iso_code"]=="RUS"]
df5=RUS_data.iloc[::25][:]
df5.head()
# India_data_copy=df4[df4["iso_code"]=="IND"]
plt.figure(figsize=(25,9))
sns.lineplot(data=df5,x="date",y="daily_vaccinations",marker='*',markersize= 15)
plt.title("Per day vaccinations population trend in RUSSIA")
plt.tight_layout()
CHINA_data=df1[df1["iso_code"]=="CHN"]
df6=CHINA_data.iloc[::25][:]
# df6.head()
plt.figure(figsize=(25,9))
sns.lineplot(data=df6,x="date",y="daily_vaccinations",marker='*',markersize= 15)
plt.title("Per day vaccinations population trends in CHINA")
plt.tight_layout()
plt.show();
unique_country_codes=df1.iso_code.unique()
# print(unique_country_codes)
total_vaccinations=[]
for i in unique_country_codes:
country_data=df1[df1["iso_code"]==i]
total_vaccinations.append([country_data['total_vaccinations_per_hundred'].sum()/len(df1),i])
total_vaccinations.sort(reverse=True)
plt.figure(figsize=(25,9))
plt.xticks(rotation=45)
#top 20
countries=total_vaccinations[:20]
country_codes=[countries[i][1] for i in range(len(countries))]
vaccinated=[countries[i][0] for i in range(len(country_codes))]
# print(vaccinated)
plt.title("Top 20 countries according to the population vaccinated per hundred on an average")
plt.bar(country_codes,vaccinated)
<BarContainer object of 20 artists>
unique_country_codes=df1.iso_code.unique()
# print(unique_country_codes)
total_vaccinations=[]
for i in unique_country_codes:
country_data=df1[df1["iso_code"]==i]
total_vaccinations.append([country_data['total_vaccinations'].sum(),i])
total_vaccinations.sort(reverse=True)
plt.figure(figsize=(25,9))
plt.xticks(rotation=45)
#top 20
countries=total_vaccinations[:20]
country_codes=[countries[i][1] for i in range(len(countries))]
vaccinated=[countries[i][0] for i in range(len(country_codes))]
# print(vaccinated)
plt.title("Top 20 countries according to the total population vaccinated")
plt.bar(country_codes,vaccinated,color = 'g')
<BarContainer object of 20 artists>
unique_country_codes=df1.iso_code.unique()
print(len(unique_country_codes))
# print(unique_country_codes)
total_vaccinations=[]
for i in unique_country_codes:
country_data=df1[df1["iso_code"]==i]
total_vaccinations.append([country_data['total_vaccinations_per_hundred'].sum()/len(df1),i])
total_vaccinations.sort()
plt.figure(figsize=(25,9))
plt.xticks(rotation=45)
#top 20
countries=total_vaccinations[:20]
country_codes=[countries[i][1] for i in range(len(countries))]
vaccinated=[countries[i][0] for i in range(len(country_codes))]
# print(vaccinated)
plt.title("Least 20 countries according to the population vaccinated per hundred on an average")
plt.bar(country_codes,vaccinated)
223
<BarContainer object of 20 artists>
unique_country_codes=df1.iso_code.unique()
print(len(unique_country_codes))
# print(unique_country_codes)
total_vaccinations=[]
for i in unique_country_codes:
country_data=df1[df1["iso_code"]==i]
total_vaccinations.append([country_data['people_fully_vaccinated'].sum(),country_data['total_vaccinations'].sum()-country_data['people_fully_vaccinated'].sum(),i])
total_vaccinations.sort(key=lambda x : x[1]-x[0],reverse=True)
plt.figure(figsize=(25,9))
plt.xticks(rotation=45)
#top 20
countries=total_vaccinations[:20]
print(countries)
country_codes=[countries[i][2] for i in range(len(countries))]
first_dose_vaccinated=[countries[i][1] for i in range(len(country_codes))]
fully_vaccinated=[countries[i][0] for i in range(len(country_codes))]
# print(vaccinated)
plt.title("Top 20 countries according to the total population vaccinated")
# plt.bar(country_codes,vaccinated,color = 'g')
width = 0.25
plt.bar(country_codes, first_dose_vaccinated, color = 'b',
width = width, edgecolor = 'black',
label='first_dose')
plt.bar(country_codes, fully_vaccinated, color = 'g',
width = width, edgecolor = 'black',
label='fully_vaccinated')
plt.legend()
plt.ylim(0, 15e10)
223 [[35263365000.0, 674189298700.0, 'CHN'], [116436444996.0, 207003860802.0, 'IND'], [66636073783.0, 88377793425.0, 'USA'], [30276933880.0, 48790240515.0, 'BRA'], [2790327552.0, 15124171600.0, 'VNM'], [14031369961.0, 22820271807.0, 'GBR'], [13059057856.0, 20864043077.0, 'TUR'], [11804284068.0, 19232829955.0, 'OWID_ENG'], [16199397881.0, 22783432451.0, 'DEU'], [13032980027.0, 19144059345.0, 'FRA'], [12123170801.0, 17589883231.0, 'ITA'], [7109532830.0, 11569418458.0, 'ARG'], [8725916008.0, 13105490027.0, 'KOR'], [12126072350.0, 16258490357.0, 'RUS'], [8014596169.0, 12003758151.0, 'THA'], [7375066347.0, 10853203300.0, 'CAN'], [12534314850.0, 15981155525.0, 'MEX'], [6237563902.0, 9440322436.0, 'PAK'], [5082636380.0, 8122442034.0, 'BGD'], [13645790941.0, 16656335987.0, 'JPN']]
(0.0, 150000000000.0)
labels=df2.vaccine.unique()
vaccine = df2.groupby(["vaccine"])['total_vaccinations'].max().reset_index()
print(vaccine)
vaccine.percent = (vaccine.total_vaccinations/vaccine.total_vaccinations.sum())*100
# print(vaccine.percent)
wedgeprops = {"linewidth": 4, 'width':1, "edgecolor":"k"} # Width = 1
textprops = {"fontsize":15}
# plt.xticks(rotation=45);
plt.pie('total_vaccinations',labels = labels, data = vaccine,radius = 2,wedgeprops = wedgeprops,
textprops=textprops, labeldistance = 0.6,);
plt.legend() # To show legend
vaccine total_vaccinations 0 CanSino 610540 1 Covaxin 11 2 Johnson&Johnson 18563903 3 Moderna 210341785 4 Novavax 184429 5 Oxford/AstraZeneca 67403106 6 Pfizer/BioNTech 600519998 7 Sinopharm/Beijing 28322602 8 Sinovac 25596927 9 Sputnik V 20405678
C:\Users\HP\AppData\Local\Temp/ipykernel_22176/1190577492.py:7: UserWarning: Pandas doesn't allow columns to be created via a new attribute name - see https://pandas.pydata.org/pandas-docs/stable/indexing.html#attribute-access
<matplotlib.legend.Legend at 0x1bef7aada60>
df2.head()
| location | date | vaccine | total_vaccinations | |
|---|---|---|---|---|
| 0 | Argentina | 2020-12-29 | Moderna | 2 |
| 1 | Argentina | 2020-12-29 | Oxford/AstraZeneca | 3 |
| 2 | Argentina | 2020-12-29 | Sinopharm/Beijing | 1 |
| 3 | Argentina | 2020-12-29 | Sputnik V | 20481 |
| 4 | Argentina | 2020-12-30 | Moderna | 2 |
import plotly.express as px
fig = px.choropleth(df1, locations="iso_code",
color="vaccines",
hover_name="country",
color_continuous_scale=px.colors.sequential.Plasma,
title= "Vaccines used by different countries")
fig.update_layout(showlegend=True)
fig.show()
fig = px.choropleth(df1, locations="iso_code",
color="source_name",
hover_name="country",
color_continuous_scale=px.colors.sequential.Plasma,
title= "Sources of vaccines for different countries")
fig.update_layout(showlegend=True)
fig.show()
plt.figure(figsize=(30,20))
sns.countplot(y='source_name', data=df1)
<AxesSubplot:xlabel='count', ylabel='source_name'>
plt.figure(figsize=(20,10))
sns.countplot(y='vaccine', data=df2)
<AxesSubplot:xlabel='count', ylabel='vaccine'>
fig = px.scatter_geo(df1, locations="iso_code", color="vaccines",
hover_name="country",
projection="natural earth", template="plotly_dark")
fig.show()
fig = px.scatter_geo(df1, locations="iso_code", color="people_vaccinated",
hover_name="country",
projection="natural earth", animation_frame="date", template="plotly_dark")
fig.show()